<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<include file="_layout/mall.head.html" />
</head>
<body class="body-fixed">
	<div class="container">
		<div class="content">
			<div id="coupon-nav" class="tabber tabber-red tabber-n2 top-fix clearfix">
				<a class="active" href="javascript:;" data-enabled="1">客服评价</a>
				<a href="javascript:;" data-enabled="0">客服投诉</a>
			</div>
			<div id="coupon-list" class="my-coupons" >
				<div class="block block-list"></div>
			</div>
		</div>
	</div>
	<include file="_layout/mall.footer.html" />
	<script type="text/javascript">
	require(['pullfresh'], function(pullfresh){
		var $nav = $('#coupon-nav'),
			$container = $('#coupon-list>.block-list')
			 enabled = 1;
		
		$container.on('click', '.js-refresh',function(){
			pullfresh.doRefresh();
			return false;
		});
		
		pullfresh.showData = function(list, page, size){
			
			if(page == 1 && list.length == 0){
				pullfresh.setNoMore('');
				$container.html('<div class="empty-list"><div><h4>暂无内容</h4><p class="font-size-12">好东西，手慢无</p></div><div><a href="" class="js-refresh tag tag-big tag-orange">刷新</a></div></div>');
				return;
			}
			pullfresh.setNoMore(list.length < size);
			
			var html = '', attitude = {5:'非常满意', 4:'满意', 3:'一般',0:'未评价'};
			for(var i=0; i<list.length; i++){
				html += '<a href="javascript:;" class="block-item'+(list[i].attitude > 0 ? ' disabled' : '')+'">';
				if(list[i].attitude != 0 && list[i].message == ''){
					html += '    <div class="block-info">';
    				html += '        <div class="block-title">微信号：'+list[i].kf_weixin+'<span class="block-tag">'+attitude[list[i].attitude]+'</span></div>';
    				html += '        <div class="block-content">微信昵称：'+list[i].kf_nick+'<span class="pull-right">'+list[i].created+'</span></div>';
    				html += '    </div>';
				}else{
					 html += '		<p class="coupon-title">微信号：'+list[i].kf_weixin+'</p>';
					 html += '		<p class="coupon-title">微信昵称：'+list[i].kf_nick+'</p>';
					 html += '   	<span style="height:20px;color:#ccc;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+list[i].message+'</span>';
					 html += '		<span class="coupon-expire" style="float:right;margin-top:20px;">投诉时间:'+list[i].created + '</span>';
				}
				html += '</a>';
			}
			
			if(page == 1){
				$container.html(html);
			}else{
				$container.append(html);
			}
		}
		
		pullfresh.init({
			refresh: true,
			size: 20,
			container: $container,
			onLoad: function(parameters){
				$.ajax({
					url: '/h5/kefu?enabled='+enabled+'&offset='+parameters.offset+'&offset='+parameters.offset+'&size='+parameters.size,
					dataType: 'json',
					success: function(list){
						pullfresh.showData(list, parameters.page, parameters.size);
					},
					error: function(){
						pullfresh.showData([], parameters.page, parameters.size);
					}
				});
			}
		});
		
		$nav.on('click', 'a', function(){
            document.body.scrollTop = 0;
			var $ele = $(this);
			if($ele.hasClass('active')){
				return false;
			}
			
			enabled = $ele.data('enabled');
			$ele.addClass('active').siblings().removeClass('active');
			pullfresh.doRefresh();
			return false;
		});
	});
	</script>
</body>
</html>